package com.example.demo.util;

import lombok.Data;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate;

public class tt {
    public static void main(String[] args) {
        //String url  ="http://rsgw-liecomm-v2-uat.mot.com/loyalty.pre/api/v1/loyalty/update/profile";
        String url  ="https://rsgw-liecomm.motorola.com/loyalty.prod/api/v1/loyalty/update/profile";
        LoyaltyJoinRequestModel loyaltyJoinRequestModel = new LoyaltyJoinRequestModel();
        loyaltyJoinRequestModel.setDateOfBirth(-1511827200);
        loyaltyJoinRequestModel.setEmailOptIn(0);
        loyaltyJoinRequestModel.setFirstName("g");
        loyaltyJoinRequestModel.setLastName("g");
        loyaltyJoinRequestModel.setUserId("zxw001@yopmail.com");


        HttpHeaders headers = new HttpHeaders();

        //headers.set("apikey", "l7d6eb23061bd14402910773e9e6168a7e");
        headers.set("apikey", "l71e61572864c8427dabefa21de6389c7e");
        HttpEntity<LoyaltyJoinRequestModel> requestEntity = new HttpEntity<>(loyaltyJoinRequestModel, headers);
        ParameterizedTypeReference<String> responseType = new ParameterizedTypeReference<String>() {
        };
        String result = new RestTemplate().exchange(url, HttpMethod.POST, requestEntity, responseType).getBody();
        System.out.println(result);
    }
    @Data
    public static class LoyaltyJoinRequestModel {

        private String country;
        private Integer dateOfBirth;
        private Integer emailOptIn;
        private String firstName;
        private String lastName;
        private String postalCode;
        private String userId;
        private String userStatus;
    }
    @Data
    public static  class LoyaltyResponse<T> {
        private String loyaltyStatus;
        private String message;
        private String messageKey;
        private int statusCode;
        private T rewardsInfo;
    }
    public void get(){}
}
